/**
 * 
 */
$(function() {
	 $('#loginForm').bootstrapValidator({
	        message: 'This value is not valid',
	        feedbackIcons: {
	            valid: 'glyphicon glyphicon-ok',
	            invalid: 'glyphicon glyphicon-remove',
	            validating: 'glyphicon glyphicon-refresh'
	        },
	        fields: {
	        	email: {
	                validators: {
	                	notEmpty: {
	                        message: 'The file is required and cannot be empty'
	                    }
	                }
	            },
	            password: {
	                validators: {
	                	notEmpty: {
	                        message: 'The file is required and cannot be empty'
	                    }
	                }
	            }
	        }
	    });
	
	 $('#kaptchaImage').click(function () {//�����֤��  
	     $(this).hide().attr('src', './getKaptchaImage.do?' + Math.floor(Math.random()*100) ).fadeIn();  
	     event.cancelBubble=true;  
	    });  
	 
	$("#lnkLogin").on("click", function() {

		$('#loginDialog').load("./ajax/loginPage.do").dialog({
			autoOpen : false,
			title : "Dialog Title",
			modal : true,
			resizable : false,
			width : 600,
			buttons : {
				"确定" : function() {
					var loginFormObject = $("#loginForm").serializeJSON();
					$.cookie('loginInfo', loginFormObject, {
						expires : 7
					});// jquery cookie  

					$("#loginForm").ajaxSubmit({
						url : "login.do",
						type : "post",
						data : loginFormObject,
						dataType : "json",
						success : function(result) {
							if (result.data) {
								location.href = "index.do";
							}

						}
					});
				},
				"取消" : function() {
					$(this).dialog("close");
				}
			}
		}).dialog('open');
	});
});

function changeCode() {  
    $('#kaptchaImage').hide().attr('src', './getKaptchaImage.do?' + Math.floor(Math.random()*100) ).fadeIn();  
    event.cancelBubble=true;  
}  
